// Army类

// 区间生成随机数
const rand = require("../js/functions.js").rand
// 中央集中型（纺缍型）区间生成随机数
const mrand = require("../js/functions.js").mrand

const Army = {
	createNew: function(id){
		const p = {
			_proto: Army,

			id: id,
			ArmyName: '', 
			belong: 0,
			leader :null,
			state: null,
			troops: [],	
			exp: 0,
		}
		// 增加小队
		// p.addTroop: function(t) {
		// 	this.troops.add(t)
		// },
		// 清理掉兵力为0的小队
		p.resetTroop = function() {  
			if (this.troops.length == 0) return
			let t = []
			for ( let i in this.troops) {
				let x = this.troops[i]
				if (x.soldiors > 0) {
					t.push(x)
				} 
			}
			this.troops = t
		}

		

		return p
	},

	init: function(p){

		return p
	}
}

const Troop = {

	createNew: function(id){
		const p = {
			_proto: Troop,

			id: id,
			army: null,
			soldiors: 0,
			trill: 0,
			morale: 0,
			
		}
		
		return p
	}
}

module.exports = {Army, Troop}